package com.dmx.cep.action.userManage;

import org.apache.struts2.config.DefaultSettings;

import com.dmx.cep.service.UserSnsService;
import com.dmx.fw.constant.ViewConstant;
import com.dmx.fw.web.struts2.action.CommonQueryAction;


/**
 *
 * @author Alex.lu
 *
 */
@SuppressWarnings("serial")
public class UserSnsAction extends CommonQueryAction {

    private static final String BATCH_DELETE = "batchDelete";
    private UserSnsService userSnsService;

	private String[] ids;
	private String id;
	private String q_uid;

    private String language;


	// actions begin

	public String execute() throws Exception {
		super.busiId = "userSnsSearch";
		if (ViewConstant.QUERY.equals(super.act)) {
			doQuery();
		} else if (ViewConstant.REQUERY.equals(super.act)) {
			doReQuery();
		} else if (ViewConstant.DELETE.equals(super.act)) {
			this.doDelete();
		} else if (BATCH_DELETE.equals(super.act)) {
			doBatchDelete();
		}else if (ViewConstant.ADDINPUT.equals(super.act)) {
			this.pageState = ViewConstant.ADDSTATUS;
			return doAddInput();
		} else if (ViewConstant.ADDSUBMIT.equals(super.act)) {
			return doAddSubmit();
		}else if (ViewConstant.EDITINPUT.equals(super.act)) {
			this.pageState = ViewConstant.EDITSTATUS;
			return doEditInput();
		} else if (ViewConstant.EDITSUBMIT.equals(super.act)) {
			return doEditSubmit();
		}else{
			super.execute();
		}
		return SUCCESS;
	}

	public String doAddInput() {
		
		return ViewConstant.ADDINPUT;
	}

	public String doAddSubmit() throws Exception {



		super.doReQuery();
		return SUCCESS;
	}

	public String doEditInput() {
		if (this.id != null) {
			this.pageState = "edit";

		}
		return ViewConstant.EDITINPUT;
	}
	
	

	public String doEditSubmit() throws Exception {


		setSuccessinfo(getText("info.addSuccess"));
		super.doReQuery();
		return SUCCESS;
	}

	public String doBatchDelete() throws Exception {
	
		return super.doQuery();
	}


	public String doDelete() throws Exception {
		setSuccessinfo(getText("info.deleteSuccess"));
		return super.doQuery();
	}



	// actions end

	// getters and setters begin





	public String[] getIds() {
		return ids;
	}

	public void setIds(String[] ids) {
		this.ids = ids;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	// getters and setters end

	public void setQ_uid(String q_uid) {
		this.q_uid = q_uid;
	}

	public String getQ_uid() {
		return q_uid;
	}

	public String getLanguage() {
		language =DefaultSettings.get("struts.locale");
		return language;
	}

	public void setUserSnsService(UserSnsService userSnsService) {
		this.userSnsService = userSnsService;
	}


}